package com.hello.web.controller;

import com.hello.common.aspect.ApiOperationLog;
import com.hello.common.utils.PageResponse;
import com.hello.common.utils.Response;
import com.hello.web.domain.bo.role.AddRoleBO;
import com.hello.web.domain.bo.role.DelRoleBO;
import com.hello.web.domain.bo.role.RoleQueryBO;
import com.hello.web.service.role.RoleService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/role")
@RequiredArgsConstructor
public class RoleController {

    private final RoleService roleService;

    @PostMapping("/page/list")
    @ApiOperation(value = "角色分页列表")
    @ApiOperationLog(description = "角色分页列表")
    public PageResponse queryRolePageList(@RequestBody @Validated RoleQueryBO bo) {
        return roleService.queryRolePageList(bo);
    }

    @PostMapping("/list")
    @ApiOperation(value = "角色列表")
    @ApiOperationLog(description = "角色列表")
    public Response queryRoleList() {
        return roleService.queryRoleList();
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增角色")
    @ApiOperationLog(description = "新增角色")
    public Response addRole(@RequestBody @Validated AddRoleBO bo) {
        return roleService.addRole(bo);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除角色")
    @ApiOperationLog(description = "删除角色")
    public Response deleteRole(@RequestBody @Validated DelRoleBO bo) {
        roleService.deleteRole(bo);
        return Response.success();
    }
}
